stage.set_background("schoolhallway")
sprite = codesters.Sprite("person8")
stage.set_gravity(4)
stage.disable_floor()
sprite.set_gravity_off()
sprite.go_to(0, -220)
score = 0
score_board = codesters.Display(score)
my_info = ["cellphone", "address", "birthdate"]
def left_key():
sprite.move_left(20)
# add other actions...
stage.event_key("left", left_key)
def right_key():
sprite.move_right(20)
# add other actions...
stage.event_key("right", right_key)
t = codesters.Teacher()
try:
tval1 = t.find_block('def')[2][1]
tval2 = t.get_indent_at_line(t.find_block('def')[2][0])
except:
tval1 = "DNE"
tval2 = "DNE"
try:
tval3 = t.find_function('event_interval')[0][1]
tval4 = t.get_indent_at_line(t.find_function('event_interval')[0][0])
except:
tval3 = "DNE"
tval4 = "DNE"
t1 = TestObjective()
t1.add_success('interval()' in tval1 and tval2 == 0, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add an Interval Event?")
t1.add_failure('interval()' not in tval1, "Make sure you add an interval event!")
t1.add_failure(tval2 > 0, "Make sure your Interval Event is outside of your Key Events and not indented at all!")
t2 = TestObjective()
t2.add_success(tval4 == 0 and '3' in tval3, "Great job!")
t2.add_failure(tval3 == "DNE", "Oops! Did you delete your event handler?")
t2.add_failure('2' in tval3, "Did you change the number in the handler to 3?")
t2.add_failure(tval4 > 0, "Make sure your event handler is not indented!")
t2.add_creative('2' not in tval3 and '3' not in tval3 and tval3 != "DNE", "That's a good amount of time, too!")
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)